home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / RCS / netEther.h,v < prev    next >
Encoding:
Text File  |  1992-08-05  |  11.2 KB  |  538 lines

  1. head     1.15;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.13.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.15
  10. date     92.08.05.16.34.40;  author jhh;  state Exp;
  11. branches ;
  12. next     1.14;
  13.  
  14. 1.14
  15. date     91.11.18.14.41.13;  author kupfer;  state Exp;
  16. branches ;
  17. next     1.13;
  18.  
  19. 1.13
  20. date     91.03.30.17.23.01;  author jhh;  state Exp;
  21. branches 1.13.1.1;
  22. next     1.12;
  23.  
  24. 1.12
  25. date     90.12.06.22.11.08;  author shirriff;  state Exp;
  26. branches ;
  27. next     1.11;
  28.  
  29. 1.11
  30. date     90.05.14.14.47.35;  author jhh;  state Exp;
  31. branches ;
  32. next     1.10;
  33.  
  34. 1.10
  35. date     89.07.31.17.41.49;  author mgbaker;  state Exp;
  36. branches ;
  37. next     1.9;
  38.  
  39. 1.9
  40. date     89.06.23.11.30.17;  author rab;  state Exp;
  41. branches ;
  42. next     1.8;
  43.  
  44. 1.8
  45. date     89.06.05.13.31.12;  author mendel;  state Exp;
  46. branches ;
  47. next     1.7;
  48.  
  49. 1.7
  50. date     89.05.31.12.33.29;  author jhh;  state Exp;
  51. branches ;
  52. next     1.6;
  53.  
  54. 1.6
  55. date     89.03.01.20.18.55;  author mendel;  state Exp;
  56. branches ;
  57. next     1.5;
  58.  
  59. 1.5
  60. date     88.11.21.09.27.40;  author mendel;  state Exp;
  61. branches ;
  62. next     1.4;
  63.  
  64. 1.4
  65. date     88.08.01.17.06.45;  author mendel;  state Exp;
  66. branches ;
  67. next     1.3;
  68.  
  69. 1.3
  70. date     88.08.01.15.02.01;  author mendel;  state Exp;
  71. branches ;
  72. next     1.2;
  73.  
  74. 1.2
  75. date     88.06.21.13.09.37;  author ouster;  state Exp;
  76. branches ;
  77. next     1.1;
  78.  
  79. 1.1
  80. date     88.06.21.13.04.44;  author ouster;  state Exp;
  81. branches ;
  82. next     ;
  83.  
  84. 1.13.1.1
  85. date     91.10.21.22.14.22;  author kupfer;  state Exp;
  86. branches ;
  87. next     ;
  88.  
  89.  
  90. desc
  91. @@
  92.  
  93.  
  94. 1.15
  95. log
  96. @added compare and copy routines
  97. @
  98. text
  99. @/*
  100.  * netEther.h --
  101.  *
  102.  *    This defines the format of an ethernet packet.
  103.  *
  104.  *    
  105.  *     The symbol NET_ETHER_BAD_ALIGNMENT must defined for machines that
  106.  *    pad or otherwise mess up the layout of the Net_EtherHdr structure.
  107.  *    This must be defined for machines such as the SPUR where structures
  108.  *    are padded to 4 byte boundries.  To test a machine to see if 
  109.  *    NET_ETHER_BAD_ALIGNMENT is needed, check sizeof(Net_EtherHdr).  If
  110.  *    this number is anything other than the size of an ethernet header 
  111.  *    (14 bytes), NET_ETHER_BAD_ALIGNMENT must be defined in the 
  112.  *    machparam.h file for the machine.
  113.  *
  114.  * Copyright 1988 Regents of the University of California
  115.  * Permission to use, copy, modify, and distribute this
  116.  * software and its documentation for any purpose and without
  117.  * fee is hereby granted, provided that the above copyright
  118.  * notice appear in all copies.  The University of California
  119.  * makes no representations about the suitability of this
  120.  * software for any purpose.  It is provided "as is" without
  121.  * express or implied warranty.
  122.  *
  123.  *
  124.  *
  125.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.14 91/11/18 14:41:13 kupfer Exp $ SPRITE (Berkeley)
  126.  */
  127.  
  128. #ifndef _NETETHER
  129. #define _NETETHER
  130.  
  131.  
  132. #include "machparam.h"
  133.  
  134. /*
  135.  * Compare two ethernet addresses.
  136.  */
  137.  
  138. #ifndef NET_ETHER_BAD_ALIGNMENT
  139.  
  140. #define    Net_EtherAddrCmp(e1,e2) Net_EtherAddrCmpPtr(&e1,&e2)
  141.  
  142. /*
  143.  * Compare bytes backward because ethernet address tend to start with the
  144.  * same few bytes.
  145.  */
  146.  
  147. #define    Net_EtherAddrCmpPtr(e1,e2) \
  148.    (!(((e1)->byte6 == (e2)->byte6) && ((e1)->byte5 == (e2)->byte5) && \
  149.     ((e1)->byte4 == (e2)->byte4) && ((e1)->byte3 == (e2)->byte3) && \
  150.     ((e1)->byte2 == (e2)->byte2) && ((e1)->byte1 == (e2)->byte1)))
  151.  
  152. #else     /* NET_ETHER_BAD_ALIGNMENT */
  153.  
  154.  
  155. #define    Net_EtherAddrCmp(e1,e2) (bcmp((e1),(e2), sizeof(Net_EtherAddress)))
  156.  
  157. #define    Net_EtherAddrCmpPtr(e1Ptr,e2Ptr) Net_EtherAddrCmp(*(e1Ptr),*(e2Ptr))
  158.  
  159. #endif /* NET_ETHER_BAD_ALIGNMENT */
  160.  
  161.  
  162. /*
  163.  * Ethernet Address - 6 bytes
  164.  */
  165. #ifndef NET_ETHER_BAD_ALIGNMENT
  166.  
  167. typedef struct {
  168.     unsigned char byte1;
  169.     unsigned char byte2;
  170.     unsigned char byte3;
  171.     unsigned char byte4;
  172.     unsigned char byte5;
  173.     unsigned char byte6;
  174. } Net_EtherAddress;
  175.  
  176. #define    NET_ETHER_ADDR_BYTE1(e)    ((e).byte1)
  177. #define    NET_ETHER_ADDR_BYTE2(e)    ((e).byte2)
  178. #define    NET_ETHER_ADDR_BYTE3(e)    ((e).byte3)
  179. #define    NET_ETHER_ADDR_BYTE4(e)    ((e).byte4)
  180. #define    NET_ETHER_ADDR_BYTE5(e)    ((e).byte5)
  181. #define    NET_ETHER_ADDR_BYTE6(e)    ((e).byte6)
  182.  
  183. #ifdef sun4
  184. #define    NET_ETHER_ADDR_COPY(src,dst)    \
  185.     ((dst).byte1 = (src).byte1);    \
  186.     ((dst).byte2 = (src).byte2);    \
  187.     ((dst).byte3 = (src).byte3);    \
  188.     ((dst).byte4 = (src).byte4);    \
  189.     ((dst).byte5 = (src).byte5);    \
  190.     ((dst).byte6 = (src).byte6)
  191. #else
  192. #define    NET_ETHER_ADDR_COPY(src,dst) ((dst) = (src))
  193. #endif
  194.  
  195. #else 
  196.  
  197. typedef unsigned char Net_EtherAddress[6];
  198.  
  199. #define    NET_ETHER_ADDR_BYTE1(e)    ((e)[0])
  200. #define    NET_ETHER_ADDR_BYTE2(e)    ((e)[1])
  201. #define    NET_ETHER_ADDR_BYTE3(e)    ((e)[2])
  202. #define    NET_ETHER_ADDR_BYTE4(e)    ((e)[3])
  203. #define    NET_ETHER_ADDR_BYTE5(e)    ((e)[4])
  204. #define    NET_ETHER_ADDR_BYTE6(e)    ((e)[5])
  205.  
  206. #define    NET_ETHER_ADDR_COPY(src,dst) \
  207.             (bcopy((src),(dst),sizeof(Net_EtherAddress)))
  208.  
  209. #endif /* NET_ETHER_BAD_ALIGNMENT */
  210.  
  211. /*
  212.  * Ethernet Header.- 14 bytes 
  213.  */
  214.  
  215. #ifndef NET_ETHER_BAD_ALIGNMENT
  216.  
  217. typedef struct {
  218.     Net_EtherAddress destination;
  219.     Net_EtherAddress source;
  220.     unsigned short   type;        /* valid types defined below */
  221. } Net_EtherHdr;
  222.  
  223. #define    NET_ETHER_HDR_DESTINATION(e)    ((e).destination)
  224. #define    NET_ETHER_HDR_SOURCE(e)        ((e).source)
  225. #define    NET_ETHER_HDR_TYPE(e)        ((e).type)
  226.  
  227. #define    NET_ETHER_HDR_DESTINATION_PTR(e)    &((e).destination)
  228. #define    NET_ETHER_HDR_SOURCE_PTR(e)        &((e).source)
  229. #define    NET_ETHER_HDR_TYPE_PTR(e)        &((e).type)
  230.  
  231. #define    NET_ETHER_HDR_COPY(src, dst) ((dst) = (src))
  232.  
  233. #else 
  234.  
  235. typedef unsigned char Net_EtherHdr[14];
  236.  
  237. #define    NET_ETHER_HDR_DESTINATION(e)    ((unsigned char *) (e))
  238. #define    NET_ETHER_HDR_SOURCE(e)        ((unsigned char *) (e+6))
  239. #define    NET_ETHER_HDR_TYPE(e)        (*((unsigned short *) (e+12)))
  240.  
  241. #define    NET_ETHER_HDR_DESTINATION_PTR(e)    ((unsigned char *) (e))
  242. #define    NET_ETHER_HDR_SOURCE_PTR(e)        ((unsigned char *) (e+6))
  243. #define    NET_ETHER_HDR_TYPE_PTR(e)        (*((unsigned short *) (e+12)))
  244.  
  245. #define    NET_ETHER_HDR_COPY(src, dst) (bcopy(src,dst,sizeof(Net_EtherHdr)))
  246.  
  247. #endif /* NET_ETHER_BAD_ALIGNMENT */
  248.  
  249. /*
  250.  * Minimum and maximum packet sizes. The maximum is actually 1518, but
  251.  * for some reason it is set here to 1514.  I wouldn't change it unless
  252.  * you're sure you won't break something in the kernel. JHH
  253.  */
  254.  
  255. #define    NET_ETHER_MIN_BYTES    64
  256. #define    NET_ETHER_MAX_BYTES    1514
  257.  
  258. /*
  259.  * Definitions of known ethernet packet types (from rfc990, except for SPRITE
  260.  * and TRAIL).
  261.  */
  262. #define NET_ETHER_PUP            0x0200
  263. #define NET_ETHER_PUP_ADDR_TRANS    0x0201
  264. #define NET_ETHER_XNS_IDP        0x0600
  265. #define NET_ETHER_IP            0x0800
  266. #define NET_ETHER_ARP            0x0806
  267. #define NET_ETHER_XNS_COMPAT        0x0807
  268. #define NET_ETHER_SPRITE        0x0500
  269. #define NET_ETHER_SPRITE_ARP        0x0502 /* deprecated */
  270. #define NET_ETHER_SPRITE_DEBUG        0x0504
  271. #define NET_ETHER_TRAIL            0x1000
  272. #define NET_ETHER_REVARP        0x8035
  273. #define NET_ETHER_MOP            0x6001
  274.  
  275. #endif /* _NETETHER */
  276. @
  277.  
  278.  
  279. 1.14
  280. log
  281. @Comment NET_ETHER_SPRITE_ARP as deprecated.
  282. @
  283. text
  284. @d27 1
  285. a27 1
  286.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.13 91/03/30 17:23:01 jhh Exp Locker: kupfer $ SPRITE (Berkeley)
  287. d35 1
  288. d42 1
  289. a42 1
  290. #define    NET_ETHER_COMPARE(e1,e2) NET_ETHER_COMPARE_PTR(&e1,&e2)
  291. d49 2
  292. a50 2
  293. #define    NET_ETHER_COMPARE_PTR(e1,e2) \
  294.    (((e1)->byte6 == (e2)->byte6) && ((e1)->byte5 == (e2)->byte5) && \
  295. d52 1
  296. a52 1
  297.     ((e1)->byte2 == (e2)->byte2) && ((e1)->byte1 == (e2)->byte1))
  298. d57 1
  299. a57 1
  300. #define    NET_ETHER_COMPARE(e1,e2) (bcmp((e1),(e2), sizeof(Net_EtherAddress))==0)
  301. d59 1
  302. a59 1
  303. #define    NET_ETHER_COMPARE_PTR(e1Ptr,e2Ptr) NET_ETHER_COMPARE(*(e1Ptr),*(e2Ptr))
  304. a61 1
  305.  
  306. @
  307.  
  308.  
  309. 1.13
  310. log
  311. @Mary checking this in for John H.  It now has a minimum packet size too.
  312. @
  313. text
  314. @d27 1
  315. a27 1
  316.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.12 90/12/06 22:11:08 shirriff Exp Locker: jhh $ SPRITE (Berkeley)
  317. d171 1
  318. a171 1
  319. #define NET_ETHER_SPRITE_ARP        0x0502
  320. @
  321.  
  322.  
  323. 1.13.1.1
  324. log
  325. @Initial branch for Sprite server.
  326. @
  327. text
  328. @d27 1
  329. a27 1
  330.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.13 91/03/30 17:23:01 jhh Exp $ SPRITE (Berkeley)
  331. @
  332.  
  333.  
  334. 1.12
  335. log
  336. @Added mop packet type.
  337. @
  338. text
  339. @d27 1
  340. a27 1
  341.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.11 90/05/14 14:47:35 jhh Exp $ SPRITE (Berkeley)
  342. d152 3
  343. a154 1
  344.  * Mininnum and maximum packet sizes.
  345. d157 1
  346. a157 1
  347. #define    NET_ETHER_MIN_BYTES    60
  348. @
  349.  
  350.  
  351. 1.11
  352. log
  353. @changed an ether address to a structure of unsigned bytes.
  354. @
  355. text
  356. @d27 1
  357. a27 1
  358.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.10 89/07/31 17:41:49 mgbaker Exp Locker: jhh $ SPRITE (Berkeley)
  359. d173 1
  360. @
  361.  
  362.  
  363. 1.10
  364. log
  365. @Structure assignment still doesn't work in gcc for the sun4.  This
  366. file needed a hack to get around this.
  367. @
  368. text
  369. @d27 1
  370. a27 1
  371.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.9 89/06/23 11:30:17 rab Exp Locker: mgbaker $ SPRITE (Berkeley)
  372. d70 6
  373. a75 6
  374.     char byte1;
  375.     char byte2;
  376.     char byte3;
  377.     char byte4;
  378.     char byte5;
  379.     char byte6;
  380. @
  381.  
  382.  
  383. 1.9
  384. log
  385. @*** empty log message ***
  386. @
  387. text
  388. @d27 1
  389. a27 1
  390.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.8 89/06/05 13:31:12 mendel Exp Locker: rab $ SPRITE (Berkeley)
  391. d85 9
  392. d95 1
  393. @
  394.  
  395.  
  396. 1.8
  397. log
  398. @Fixed NET_ETHER_COMPARE() macro for NET_ETHER_BAD_ALIGNMENT case.
  399. @
  400. text
  401. @d27 1
  402. a27 1
  403.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.7 89/05/31 12:33:29 jhh Exp Locker: mendel $ SPRITE (Berkeley)
  404. d60 1
  405. a60 1
  406. #endif NET_ETHER_BAD_ALIGNMENT
  407. d101 1
  408. a101 1
  409. #endif NET_ETHER_BAD_ALIGNMENT
  410. d139 1
  411. a139 1
  412. #endif NET_ETHER_BAD_ALIGNMENT
  413. d164 1
  414. a164 1
  415. #endif _NETETHER
  416. @
  417.  
  418.  
  419. 1.7
  420. log
  421. @added macros for getting pointers to fields of ether header
  422. @
  423. text
  424. @d27 1
  425. a27 1
  426.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.6 89/03/01 20:18:55 mendel Exp $ SPRITE (Berkeley)
  427. d56 1
  428. a56 1
  429. #define    NET_ETHER_COMPARE(e1,e2) (bcmp((e1),(e2), sizeof(Net_EtherHdr)) == 0)
  430. @
  431.  
  432.  
  433. 1.6
  434. log
  435. @Make packet type in ethernet header unsigned.
  436. @
  437. text
  438. @d27 1
  439. a27 1
  440.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.5 88/11/21 09:27:40 mendel Exp $ SPRITE (Berkeley)
  441. d119 4
  442. d132 4
  443. @
  444.  
  445.  
  446. 1.5
  447. log
  448. @Added a few more lines of explaination of NET_ETHER_BAD_ALIGNMENT.
  449. @
  450. text
  451. @d27 1
  452. a27 1
  453.  * $Header: /sprite/src/lib/include/RCS/netEther.h,v 1.4 88/08/01 17:06:45 mendel Exp Locker: mendel $ SPRITE (Berkeley)
  454. d112 1
  455. a112 1
  456.     short              type;        /* valid types defined below */
  457. @
  458.  
  459.  
  460. 1.4
  461. log
  462. @Modified to include machparam.h
  463. @
  464. text
  465. @d7 1
  466. a7 1
  467.  *     The symbol NET_ETHER_BAD_ALIGNMENT maybe defined for machines that
  468. d9 6
  469. d27 1
  470. a27 1
  471.  * $Header: netEther.h,v 1.3 88/08/01 15:02:01 mendel Exp $ SPRITE (Berkeley)
  472. @
  473.  
  474.  
  475. 1.3
  476. log
  477. @Added declarations for machines that can't handle ethernet headers in 
  478. structures because of alignment or padding problems.
  479. @
  480. text
  481. @d21 1
  482. a21 1
  483.  * $Header: netEther.h,v 2.0 87/08/11 09:32:25 brent Exp $ SPRITE (Berkeley)
  484. d27 2
  485. @
  486.  
  487.  
  488. 1.2
  489. log
  490. @*** empty log message ***
  491. @
  492. text
  493. @a4 3
  494.  *    It is usually the responsibility of the device driver
  495.  *    to format is packet in this way before copying the packet
  496.  *    into the controller's buffers.
  497. d6 5
  498. a10 1
  499.  * Copyright 1985, 1988 Regents of the University of California
  500. d19 3
  501. a21 1
  502.  * $Header: netEther.h,v 1.1 88/06/21 13:04:44 ouster Exp $ SPRITE (Berkeley)
  503. d31 1
  504. a31 3
  505. #define    NET_ETHER_COMPARE(e1, e2) \
  506.     (*(int *) &(e1) == *(int *) &(e2) && \
  507.      *(short *) &((e1).byte5) == *(short *) &((e2).byte5))
  508. d33 1
  509. a33 3
  510. #define    NET_ETHER_COMPARE_PTR(e1Ptr, e2Ptr) \
  511.     (*(int *)(e1Ptr) == *(int *)(e2Ptr) && \
  512.      *(short *)&((e1Ptr)->byte5) == *(short *)&((e2Ptr)->byte5))
  513. d36 21
  514. d59 2
  515. d70 25
  516. d96 1
  517. a96 1
  518.  * Ethernet Header.
  519. d99 2
  520. d106 18
  521. @
  522.  
  523.  
  524. 1.1
  525. log
  526. @Initial revision
  527. @
  528. text
  529. @d9 8
  530. a16 2
  531.  * Copyright 1985 Regents of the University of California
  532.  * All rights reserved.
  533. d18 1
  534. a18 2
  535.  *
  536.  * $Header: netEther.h,v 2.0 87/08/11 09:32:25 brent Exp $ SPRITE (Berkeley)
  537. @
  538.